import * as ExcelJs from 'exceljs';
import saveWorkbook from './SaveExcel'
import generateHeaders from './GenerateHeader'

const onExportBasicExcel = function (col, List,name) {
  // 创建工作簿
  const workbook = new ExcelJs.Workbook();
  // 添加sheet
  const worksheet = workbook.addWorksheet('demo sheet');
  // 设置 sheet 的默认行高
  worksheet.properties.defaultRowHeight = 20;
  // 设置列
  worksheet.columns = generateHeaders(col);
  // 添加行
  worksheet.addRows(List);
  // 导出excel
  name = name + '.xlsx'
  saveWorkbook(workbook, name);
}

export default onExportBasicExcel